package md.mru.core.dtos;

import md.mru.core.domains.type.NodeType;

import java.util.*;

/**
 * @author sergiu.marin
 * @since 14.04.2014.
 */
public class TreeNodeModelDto {

    private long id;
    private TreeNodeModelDto parentNode;
    private String name;
    private String description;
    private Double position;
    private TreeNodeTypeDto treeNodeType;
    private Set<TreeFolderDto> treeFolders = new HashSet<>();
    private Set<TreeModelUserGroupDto> groups = new HashSet<>();
    private String phoneNo;
    private String officeLocation;
    /*private String phoneNo2;
    private String phoneNo3;*/
    /*private Date validateFrom = new Date();
    private Date validateTo;*/
    private boolean moved;
    private static Comparator<TreeFolderDto> TREE_FOLDERS_ACTIVE_TYPE_COMPARATOR = new Comparator<TreeFolderDto>() {
        @Override
        public int compare(TreeFolderDto o1, TreeFolderDto o2) {
            if (o1.isActive() == o2.isActive()) {
                return 0;
            }
            return o1.isActive() ? -1 : 1;
        }
    };

    public TreeNodeModelDto() {
        super();
    }

    public TreeNodeModelDto(String name) {
        this.name = name;
        treeNodeType = new TreeNodeTypeDto();
        treeNodeType.setNodeType(NodeType.FOLDER);
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public TreeNodeModelDto getParentNode() {
        return parentNode;
    }

    public void setParentNode(TreeNodeModelDto parentNode) {
        this.parentNode = parentNode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Double getPosition() {
        return position;
    }

    public void setPosition(Double position) {
        this.position = position;
    }

    public TreeNodeTypeDto getTreeNodeType() {
        return treeNodeType;
    }

    public void setTreeNodeType(TreeNodeTypeDto treeNodeType) {
        this.treeNodeType = treeNodeType;
    }

    public List<TreeFolderDto> getTreeFoldersAsList() {
        if (treeFolders != null) {
            List<TreeFolderDto> treeFolderList = new ArrayList<TreeFolderDto>(treeFolders);
            Collections.sort(treeFolderList, TREE_FOLDERS_ACTIVE_TYPE_COMPARATOR);
            return treeFolderList;
        }
        return null;
    }

    public Set<TreeModelUserGroupDto> getGroups() {
        return groups;
    }

    public void setGroups(Set<TreeModelUserGroupDto> groups) {
        this.groups = groups;
    }

    public Set<TreeFolderDto> getTreeFolders() {
        return treeFolders;
    }

    public void setTreeFolders(Set<TreeFolderDto> treeFolders) {
        this.treeFolders = treeFolders;
    }

    public String getPhoneNo() {
        return phoneNo;
    }

    public void setPhoneNo(String phoneNo) {
        this.phoneNo = phoneNo;
    }

    public String getOfficeLocation() {
        return officeLocation;
    }

    public void setOfficeLocation(String officeLocation) {
        this.officeLocation = officeLocation;
    }

    /*    public String getPhoneNo2() {
        return phoneNo2;
    }

    public void setPhoneNo2(String phoneNo2) {
        this.phoneNo2 = phoneNo2;
    }

    public String getPhoneNo3() {
        return phoneNo3;
    }

    public void setPhoneNo3(String phoneNo3) {
        this.phoneNo3 = phoneNo3;
    }*/

/*    public Date getValidateFrom() {
        return validateFrom;
    }

    public void setValidateFrom(Date validateFrom) {
        this.validateFrom = validateFrom;
    }

    public Date getValidateTo() {
        return validateTo;
    }

    public void setValidateTo(Date validateTo) {
        this.validateTo = validateTo;
    }*/

    public boolean hasMoved() {
        return moved;
    }

    public void setMoved(boolean moved) {
        this.moved = moved;
    }
}
